package cockpit.desarollo.SERVICE;

import java.sql.SQLException;
import java.util.ArrayList;

import cockpit.comm.DTO.DatosException;
import cockpit.comm.DTO.UsuarioDTO;
import cockpit.desarollo.DAO.UsuarioDAO;


public class UsuarioSERVICE
{
    private static UsuarioDAO dao;

    private static UsuarioDAO getDAO( )
    {
        if( dao == null )
        {
            dao = new UsuarioDAO( );
        }
        return dao;
    }

    public static boolean login(String email, String password) throws DatosException, SQLException{
        return getDAO( ).existeEmailPassword( email,  password);
    }
    
    public static void createBasicUSer(String email, String password) throws DatosException, SQLException{
        getDAO( ).AgregarUsuarioBasic( email, password );
    }
    
    public UsuarioDTO getUsuarioPasswordEmail(String email,String password) throws SQLException, DatosException{
        return getDAO( ).getUsuarioPasswordEmail( email, password );
    }
    
    
    
    public static void cambiarEmail(String emailini, String emailfinal) throws DatosException{
        getDAO( ).cambiarEmail( emailini, emailfinal );
    }
    
    public static ArrayList<UsuarioDTO> getUsersEmail(String email) throws DatosException, SQLException{
        return getDAO( ).getUsuariosEmail( email );
    }
    
    public static void eliminarUsuario(String email) throws DatosException, SQLException{
        getDAO( ).eliminarUsuario( email );
    }
    
   
        

}
